package btanalyzer.db.model;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;

@Entity
@Table(name="TORRENT", uniqueConstraints={
		@UniqueConstraint(columnNames={"METADATA_FILE_PATH"}, name="TORRENT__METADATA_FILE_PATH_UK")
})
public class Torrent {
	
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq")
    @SequenceGenerator(name = "seq", sequenceName = "TORRENT_SEQ")
    @Column(name="TORRENT_ID")
	private Long id;
	public void setId(Long id) {
		this.id = id;
	}
	public Long getId() {
		return id;
	}
	
	@NotNull
    @Column(name="METADATA_FILE_PATH")
    private String metadataFilePath;
	public void setMetadataFilePath(String metadataFilePath) {
		this.metadataFilePath = metadataFilePath;
	}
	public String getMetadataFilePath() {
		return metadataFilePath;
	}
	
    @NotNull
    @Column(name="METADATA_URL")
    private String metadataUrl;
    public void setMetadataUrl(String metadataUrl) {
		this.metadataUrl = metadataUrl;
	}
    public String getMetadataUrl() {
		return metadataUrl;
	}

    @NotNull
    @Column(name="SEEDS")
    private Integer seeds;
    public void setSeeds(Integer seeds) {
		this.seeds = seeds;
	}
    public Integer getSeeds() {
		return seeds;
	}

    @NotNull
    @Column(name="PEERS")
    private Integer peers;
    public void setPeers(Integer peers) {
		this.peers = peers;
	}
    public Integer getPeers() {
		return peers;
	}

    @Column(name="ADDITIONAL_INFO")
    private String additionalInfo;
    public void setAdditionalInfo(String additionalInfo) {
		this.additionalInfo = additionalInfo;
	}
    public String getAdditionalInfo() {
		return additionalInfo;
	}

    @Column(name="UPLADED_DATE")
    private Date uploadedDate;
    public void setUploadedDate(Date uploadedDate) {
		this.uploadedDate = uploadedDate;
	}
    public Date getUploadedDate() {
		return uploadedDate;
	}
    
    @NotNull
    @ManyToOne
    @JoinColumn(name="DIGGED_SITE_ID")
    private DiggedSite diggedSite;
    public void setDiggedSite(DiggedSite diggedSite) {
		this.diggedSite = diggedSite;
	}
    public DiggedSite getDiggedSite() {
		return diggedSite;
	}
    
    @OneToOne(cascade=CascadeType.ALL)
    @JoinColumn(name="METADATA_ID")
    private Metadata metadata;
    public void setMetadata(Metadata metadata) {
		this.metadata = metadata;
	}
    public Metadata getMetadata() {
		return metadata;
	}

}
